package com.shugl.study.algorithm;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * Description
 *
 * @author Shugl
 * @version 1.0
 * @since 2021/4/16 16:04
 */
public class TowSum {


    public static void main(String[] args) {
        towSum(new int[]{2, 7, 11, 15}, 18);
        System.out.println(3 >>> 1);
    }

    public static void towSum(int[] nums, int target) {
        Map<Integer, Integer> map = new HashMap<>(nums.length << 2);
        for (int i = 0; i < nums.length; i++) {
            int temp = target - nums[i];
            if (map.containsKey(temp)) {
                System.out.println(Arrays.toString(new int[]{map.get(temp), i}));
                return;
            }
            map.put(nums[i], i);
        }
    }
}
